package com.woniuxy.controller;


import com.woniuxy.entity.Address;
import com.woniuxy.service.AddressService;
import com.woniuxy.utils.JWTUtil;
import com.woniuxy.utils.ResponseResults;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/address")
public class AddressController {

    @Resource
    private AddressService addressService;


    @GetMapping("/all")
    public ResponseResults<List<Address>> findByCategoryId(HttpServletRequest request){

        int getuid = JWTUtil.getuid(request.getHeader("authorization"));
        System.out.println("getuid:"+getuid);

        ResponseResults<List<Address>> address = addressService.findAddressByUid(getuid);
        System.out.println("address:"+ address);

        return address;
    }



}
